\hypertarget{format__dst_8c}{}\doxysubsection{extern/libembroidery/src/formats/format\+\_\+dst.c File Reference}
\label{format__dst_8c}\index{extern/libembroidery/src/formats/format\_dst.c@{extern/libembroidery/src/formats/format\_dst.c}}
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$math.\+h$>$}\newline
{\ttfamily \#include \char`\"{}../embroidery\+\_\+internal.\+h\char`\"{}}\newline
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{format__dst_8c_a3a8b58c49032f7403303dd1bdabd8ead}{cci}}(c1,  c2)~(c1$\ast$256+c2)
\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \mbox{\hyperlink{format__dst_8c_aa57ada775f74c81ecd2dd436aa442829}{decode\+\_\+record\+\_\+flags}} (unsigned char b2)
\item 
void \mbox{\hyperlink{format__dst_8c_a689bda45b58b2922d890a1ddf669463b}{encode\+\_\+record}} (FILE $\ast$file, int x, int y, int flags)
\item 
void \mbox{\hyperlink{format__dst_8c_aaa10e861e196d8f74ea00f21a4277e83}{set\+\_\+dst\+\_\+variable}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$pattern, char $\ast$var, char $\ast$val)
\item 
char \mbox{\hyperlink{format__dst_8c_ab8db2805e9b776e2e9e2ffbcd05f4f90}{read\+Dst}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$pattern, FILE $\ast$file)
\item 
char \mbox{\hyperlink{format__dst_8c_a5b971603eb8cc707cfd0167659fd8aab}{write\+Dst}} (\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$pattern, FILE $\ast$file)
\end{DoxyCompactItemize}


\doxysubsubsection{Detailed Description}
.DST (Tajima) embroidery file read/write routines Format comments are thanks to \href{mailto:tspilman@dalcoathletic.com}{\texttt{ tspilman@dalcoathletic.\+com}} who\textquotesingle{}s notes appeared at \href{http://www.wotsit.org}{\texttt{ http\+://www.\+wotsit.\+org}} under Tajima Format.\hypertarget{format__dst_8c_tajima-dst-format}{}\doxyparagraph{Tajima Embroidery Format (.\+dst)}\label{format__dst_8c_tajima-dst-format}
\index{dst@{dst}} \index{Tajima@{Tajima}}

Stitch Only Format. \mbox{[}X\mbox{]} Basic Read Support \mbox{[}X\mbox{]} Basic Write Support \mbox{[} \mbox{]} Well Tested Read \mbox{[} \mbox{]} Well Tested Write

.DST (Tajima) embroidery file read/write routines Format comments are thanks to \href{tspilman@dalcoathletic.com}{\texttt{ tspilman@dalcoathletic.\+com}} who\textquotesingle{}s notes appeared at \href{http://www.wotsit.org}{\texttt{ http\+://www.\+wotsit.\+org}} under Tajima Format.

Other references\+: \cite{kde_tajima} , \cite{acatina} .\hypertarget{format__dst_8c_dst-header}{}\doxysubparagraph{Header}\label{format__dst_8c_dst-header}
The header contains general information about the design. It is in lines of ASCII, so if you open a DST file as a text file, it\textquotesingle{}s the only part that\textquotesingle{}s easy to read. The line ending symbol is \`{}0x0D\}. The header is necessary for the file to be read by most softwares and hardwares.

The header is 125 bytes of data followed by padding spaces to make it 512 bytes in total.

The lines are as follows.

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{4}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Label}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Size}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Description}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Example}    }\\\cline{1-4}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Label}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Size}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Description}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Example}    }\\\cline{1-4}
\endhead
{\ttfamily LA\+:}   &17   &The design name with no path or extension. The space reserved is 16 characters, but the name must not be longer than 8 and be padded to 16 with spaces (0x20).   &{\ttfamily \char`\"{}\+LA\+:\+Star            \char`\"{}}    \\\cline{1-4}
{\ttfamily ST\+:}   &8   &The stitch count. An integer in the format {\ttfamily \%07d}, that is\+: a 7 digit number padded by leading zeros. This is the total accross all possible stitch flags.   &\\\cline{1-4}
{\ttfamily CO\+:}   &4   &The number of color changes (not to be confused with thread count, an all black design we would have the record \textbackslash{}textbf\{000\}). An integer in the format {\ttfamily \%03d}, that is\+: a 3 digit number padded by leading zeros.   &\\\cline{1-4}
{\ttfamily +X\+:}   &6   &The extent of the pattern in the postitive x direction in millimeters. An integer in the format {\ttfamily \%05d}, that is\+: a 5 digit number padded by leading zeros.   &\\\cline{1-4}
{\ttfamily -\/X\+:}   &6   &The extent of the pattern in the negative x direction in millimeters. An integer in the format {\ttfamily \%05d}, that is\+: a 5 digit integer padded by leading zeros.   &\\\cline{1-4}
{\ttfamily +Y\+:}   &6   &The extent of the pattern in the postitive y direction in millimeters. An integer in the format {\ttfamily \%05d}, that is\+: a 5 digit integer padded by leading zeros.   &\\\cline{1-4}
{\ttfamily -\/Y\+:}   &6   &The extent of the pattern in the negative y direction in millimeters. An integer in the format {\ttfamily \%05d}, that is\+: a 5 digit integer padded by leading zeros.   &\\\cline{1-4}
{\ttfamily AX\+:}   &7   &The difference of the end from the start in the x direction in 0.\+1mm, the first char should be the sign, followed by an integer in the format {\ttfamily \%05d}, that is\+: a 5 digit integer padded by leading zeros.   &\\\cline{1-4}
{\ttfamily AY\+:}   &7   &The difference of the end from the start in the y direction in 0.\+1mm, the first char should be the sign, followed by an integer in the format {\ttfamily \%05d}, that is\+: a 5 digit integer padded by leading zeros.   &\\\cline{1-4}
{\ttfamily MX\+:}   &7   &The x co-\/ordinate of the last point in the previous file should the design span multiple files. Like AX, it is the sign, followed by a 5 digit integer. If we have a one file design set it to zero.   &\\\cline{1-4}
{\ttfamily MY\+:}   &7   &The y co-\/ordinate of the last point in the previous file should the design span multiple files. Like AY, it is the sign, followed by a 5 digit integer. If we have a one file design set it to zero.   &\\\cline{1-4}
{\ttfamily PD\+:}   &10   &Information about multivolume designs.   &\\\cline{1-4}
\end{longtabu}
\hypertarget{format__dst_8c_dst-stitch-data}{}\doxysubparagraph{Stitch Data}\label{format__dst_8c_dst-stitch-data}
Uses 3 byte per stitch encoding with the format as follows\+:

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{9}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Bit}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 7}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 6}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 5}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 4}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 3}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 2}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 1}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 0}    }\\\cline{1-9}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape Bit}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 7}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 6}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 5}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 4}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 3}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 2}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 1}   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ {\itshape 0}    }\\\cline{1-9}
\endhead
Byte 0   &y+1   &y-\/1   &y+9   &y-\/9   &x-\/9   &x+9   &x-\/1   &x+1    \\\cline{1-9}
Byte 1   &y+3   &y-\/3   &y+27   &y-\/27   &x-\/27   &x+27   &x-\/3   &x+3    \\\cline{1-9}
Byte 2   &jump   &color change   &y+81   &y-\/81   &x-\/81   &x+81   &set   &set   \\\cline{1-9}
\end{longtabu}


T01 and Tap appear to use Tajima Ternary.

Where the stitch type is determined as\+:

Normal Stitch {\ttfamily 0b00000011 0x03} Jump Stitch {\ttfamily 0b10000011 0x83} Stop/\+Change Color {\ttfamily 0b11000011 0x\+C3} End Design {\ttfamily 0b11110011 0x\+F3}

Inclusive or\textquotesingle{}ed with the last byte.

Note that the max stitch length is the largest sum of \$1+3+9+27+81=121\$ where the unit length is 0.\+1mm so 12.\+1mm. The coordinate system is right handed. 

\doxysubsubsection{Macro Definition Documentation}
\mbox{\Hypertarget{format__dst_8c_a3a8b58c49032f7403303dd1bdabd8ead}\label{format__dst_8c_a3a8b58c49032f7403303dd1bdabd8ead}} 
\index{format\_dst.c@{format\_dst.c}!cci@{cci}}
\index{cci@{cci}!format\_dst.c@{format\_dst.c}}
\doxyparagraph{\texorpdfstring{cci}{cci}}
{\footnotesize\ttfamily \#define cci(\begin{DoxyParamCaption}\item[{}]{c1,  }\item[{}]{c2 }\end{DoxyParamCaption})~(c1$\ast$256+c2)}



\doxysubsubsection{Function Documentation}
\mbox{\Hypertarget{format__dst_8c_aa57ada775f74c81ecd2dd436aa442829}\label{format__dst_8c_aa57ada775f74c81ecd2dd436aa442829}} 
\index{format\_dst.c@{format\_dst.c}!decode\_record\_flags@{decode\_record\_flags}}
\index{decode\_record\_flags@{decode\_record\_flags}!format\_dst.c@{format\_dst.c}}
\doxyparagraph{\texorpdfstring{decode\_record\_flags()}{decode\_record\_flags()}}
{\footnotesize\ttfamily int decode\+\_\+record\+\_\+flags (\begin{DoxyParamCaption}\item[{unsigned char}]{b2 }\end{DoxyParamCaption})}

\mbox{\Hypertarget{format__dst_8c_a689bda45b58b2922d890a1ddf669463b}\label{format__dst_8c_a689bda45b58b2922d890a1ddf669463b}} 
\index{format\_dst.c@{format\_dst.c}!encode\_record@{encode\_record}}
\index{encode\_record@{encode\_record}!format\_dst.c@{format\_dst.c}}
\doxyparagraph{\texorpdfstring{encode\_record()}{encode\_record()}}
{\footnotesize\ttfamily void encode\+\_\+record (\begin{DoxyParamCaption}\item[{FILE $\ast$}]{file,  }\item[{int}]{x,  }\item[{int}]{y,  }\item[{int}]{flags }\end{DoxyParamCaption})}

\mbox{\Hypertarget{format__dst_8c_ab8db2805e9b776e2e9e2ffbcd05f4f90}\label{format__dst_8c_ab8db2805e9b776e2e9e2ffbcd05f4f90}} 
\index{format\_dst.c@{format\_dst.c}!readDst@{readDst}}
\index{readDst@{readDst}!format\_dst.c@{format\_dst.c}}
\doxyparagraph{\texorpdfstring{readDst()}{readDst()}}
{\footnotesize\ttfamily char read\+Dst (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{pattern,  }\item[{FILE $\ast$}]{file }\end{DoxyParamCaption})}

\mbox{\Hypertarget{format__dst_8c_aaa10e861e196d8f74ea00f21a4277e83}\label{format__dst_8c_aaa10e861e196d8f74ea00f21a4277e83}} 
\index{format\_dst.c@{format\_dst.c}!set\_dst\_variable@{set\_dst\_variable}}
\index{set\_dst\_variable@{set\_dst\_variable}!format\_dst.c@{format\_dst.c}}
\doxyparagraph{\texorpdfstring{set\_dst\_variable()}{set\_dst\_variable()}}
{\footnotesize\ttfamily void set\+\_\+dst\+\_\+variable (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{pattern,  }\item[{char $\ast$}]{var,  }\item[{char $\ast$}]{val }\end{DoxyParamCaption})}

\mbox{\Hypertarget{format__dst_8c_a5b971603eb8cc707cfd0167659fd8aab}\label{format__dst_8c_a5b971603eb8cc707cfd0167659fd8aab}} 
\index{format\_dst.c@{format\_dst.c}!writeDst@{writeDst}}
\index{writeDst@{writeDst}!format\_dst.c@{format\_dst.c}}
\doxyparagraph{\texorpdfstring{writeDst()}{writeDst()}}
{\footnotesize\ttfamily char write\+Dst (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{embroidery_8h_a168c2ed6c7e17dd1aa7755aabc1db314}{Emb\+Pattern}} $\ast$}]{pattern,  }\item[{FILE $\ast$}]{file }\end{DoxyParamCaption})}

